package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import tools.readconfig;

public class ExtractFromWgrib2Tool {
	public void Wgrib2Tool() {
		File file = new File("E:\\java_data_pre\\grib2day\\cirl\\day\\123");
		file.delete();
		String command = "wgrib2 -d 329 "
				+ "E:\\java_data_pre\\grib2day\\cirl\\2011\\T639GSI2GRIB2_ORIG_2011010112\\gda.639.2011010112000.grb2"
				+ " -no_header -append -bin "
				+ "E:\\java_data_pre\\grib2day\\cirl\\day\\123";

		System.out.println(command);
		String FileName = null/*readconfig.GetInstance().GetPath()*/;
		Runtime r = Runtime.getRuntime();
		Process p = null;
		try {
			p = r.exec(command);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(p
				.getInputStream()));
		StringBuffer sb = new StringBuffer();
		String inline;
		try {
			while (null != (inline = br.readLine())) {
				sb.append(inline).append("\n");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(sb.toString());

	}
}
